home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Easiest way to center a string?
- Date: 21 Feb 1996 04:07:46 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb20210746@qcd.lanl.gov>
- References: <4fobka$1st@parlor.hiwaay.net> <DMqEG5.8z4@eskimo.com>
- <4frif5$e6p@fohnix.metronet.com> <DMuuzG.1yK@eskimo.com>
- <4gbmmo$m5v@airdmhor.gen.nz> <4gdgs0$jg6@airdmhor.gen.nz>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: gumboot@airdmhor.gen.nz's message of 21 Feb 1996 11:10:07 +1300
-
- In article <4gdgs0$jg6@airdmhor.gen.nz> gumboot@airdmhor.gen.nz (Simon
- Hosie) writes:
- <snip>
- > printf("%*s\n", (strlen(String - LineLen) / 2, String);
-
- Sorry, make that:
-
- printf("%*s\n", (strlen(String + LineLen)) / 2, String);
-
- Here is a program I tried:
-
- #include <stdio.h>
- #include <string.h>
- int main(void) {
- const char *String = "Hello";
- int LineLen = 80;
- printf("%*s\n", (strlen(String + LineLen)) / 2, String);
- return 0;
- }
-
- and here is what my compiler tells me:
-
- junk.c: In function `main':
- junk.c:5: warning: field width is not type int (arg 2)
-
- Can you figure out what happened?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-